package cn.wolfcode.plus.qo;

import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.util.List;

@Getter
@Setter
@NoArgsConstructor
public class PageResult<T> {
    Long totalPage;

    Long currentPage;
    Long pageSize;

    List<T> data;

    public PageResult(IPage<T> page) {
        this.currentPage = page.getCurrent();
        this.pageSize = page.getSize();
        this.totalPage = page.getTotal() % pageSize == 0 ?
                page.getTotal() / pageSize :
                page.getTotal() / pageSize + 1;
        this.data = page.getRecords();
    }

}
